package com.heima.wemedia.scan.XxlJob;

import com.heima.model.wemedia.entity.WmNews;
import com.heima.wemedia.scan.dao.WmNewsDao;
import com.heima.wemedia.scan.service.WmNewsAutoScanService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;

@Component
public class XxlArticleJob {

    @Resource
    private WmNewsDao wmNewsDao;

    @Resource
    private WmNewsAutoScanService wmNewsAutoScanService;

    @XxlJob("leadnewsAutoScanJob")
    public void XxlJob(){

      List<WmNews> wmNewsList= wmNewsDao.queryResult();

      if(wmNewsList.size() > 0){
          wmNewsList.forEach(wmNews -> wmNewsAutoScanService.saveArticle(wmNews));
      }

    }
}
